<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta name="format-detection" content="telephone=no">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="author" content="johnye">
		<meta name="copyright" content="">
		<meta name="description" content="">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>小江湖</title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/aui.css" />
		<link type="text/css" rel="stylesheet" href="css/common.css">
		<link type="text/css" rel="stylesheet" href="css/master.css">
		<link rel="stylesheet" type="text/css" href="css/jscrollpane1.css" />
		<link rel="stylesheet" type="text/css" href="css/shop_nr.css" />
		<link rel="stylesheet" href="css/chat_index.css">
		<link rel="stylesheet" href="css/room_pipei.css">
		<link rel="stylesheet" href="css/room.css">
		<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
		<script src="http://hammerjs.github.io/dist/hammer.min.js "></script>
		<style>
			body {
				background: #fff;
			}
			
			.match {
				position: relative;
				border: 1px solid #ddd;
			}
			
			.match .title {
				top: -15px;
				left: 50%;
				margin-left: -46px;
				border-radius: 5px;
				padding: 0 20px;
				color: #fff;
				font: 14px/30px "";
				background: #0976e5;
			}
			
			.match p {
				text-align: center;
				padding-top: 20px;
				font: 14px/40px "";
				background: #f5f5f5;
			}
			
			.match ul li {
				text-align: center;
				line-height: 40px;
			}
			
			.match ul li img {
				width: 40px;
				height: 40px;
				border-radius: 50%;
				margin: 5px 10px;
				display: inline-block;
				vertical-align: middle;
			}
			
			@media (max-width: 330px) {
				.dc_sub_box li img {
					display: block;
					margin: 0 auto;
					width: 40px;
					height: 40px;
					!important;
				}
				.pipei-zb {
					top: 22px;
				}
				.pipei-zb1 {
					top: 22px;
				}
			}
		</style>

	</head>

	<body>
		<div class="main_warp">
			<header class="header">
				<div class="head">
					<div class="lf left_menus">
						<a href="javascript:history.go(-1);" id="left_menus_cont"><i class="iconfont fontcolor4 f20">&#xe610;</i></a>
					</div>
					<div class="lf logos">创建房间</div>
				</div>
			</header>
			<!--header end-->

			<div class="fix" style=" padding:70px 10px 20px;background:#fffde6; border-bottom: 1px solid #ddd;z-index:1;">
				<div class="mui-row mui-text-center aui-mar-b-5">
				
					<div class="mui-col-sm-3 mui-col-xs-3 ">
						<img class="aui-col-5" id="user_logo1" src="images/suowei.png" alt="" />
						<div  id="user_name1">无</div>
						<div class=" ab aui-background-red aui-color-white aui-border-radius-15" style="padding:2px 8px;right:5px;bottom:16px;">房主</div>
						<p class="ab number_red">1</p>
					</div>
					
					<div class="mui-col-sm-3 mui-col-xs-3">
						<img class="aui-col-5 " id="user_logo2" src="images/suowei.png" alt="" />
						<div id="user_name2">无</div>
						<p class="ab number_red">2</p>
					</div>
					<div class="mui-col-sm-3 mui-col-xs-3">
						<img class="aui-col-5 " id="user_logo3" src="images/suowei.png" alt="" />
						<div id="user_name3">无</div>
						<p class="ab number_red">3</p>
					</div>
					<div class="mui-col-sm-3 mui-col-xs-3">
						<img class="aui-col-5 " id="user_logo4" src="images/suowei.png" alt="" />
						<div id="user_name4">无</div>
						<p class="ab number_red">4</p>
					</div>
					<div class="mui-col-sm-3 mui-col-xs-3 ">
						<img class="aui-col-5 " id="user_logo5" src="images/suowei.png" alt="" />
						<div id="user_name5">无</div>
						<p class="ab number_red">5</p>
					</div>
					<div class="mui-col-sm-3 mui-col-xs-3">
						<img class="aui-col-5 " id="user_logo6" src="images/suowei.png" alt="" />
						<div id="user_name6">无</div>
						<p class="ab number_red">6</p>
					</div>
					<div class="mui-col-sm-3 mui-col-xs-3">
						<img class="aui-col-5 " id="user_logo7" src="images/suowei.png" alt="" />
						<div id="user_name7">无</div>
						<p class="ab number_red">7</p>
					</div>
					<div class="mui-col-sm-3 mui-col-xs-3">
						<img class="aui-col-5 " id="user_logo8" src="images/suowei.png" alt="" />
						<div id="user_name8">无</div>
						<p class="ab number_red">8</p>
					</div>
				</div>
				<div class="ab" style="bottom:-20px;left:30%;z-index: 10;">
					<button class="a_zb room_btn aui-mar-5 f14">准备</button>
					<button class="a_yq room_btn aui-mar-5 f14" style="background:#f57120">邀请</button>
				</div>
			</div>
			<!--玩家-->
			<div class=" aui-background-white re" id="liaotianneirong" style="margin-top:268px; height:350px;overflow:auto;margin-bottom: 60px;padding: 0 16px;">

				<!--聊天框-->
			</div>
			
			<div class="talk_word">
				<img src="images/voice.png" alt="" width="30" style="vertical-align:middle;" />
				<input style="width: 60%" id="liaotian" class="messages emotion" autocomplete="off" value="在这里输入文字" onFocus="if(this.value=='在这里输入文字'){this.value='';}" onblur="if(this.value==''){this.value='在这里输入文字';}" />
				<img id="xiaolian" style="position: absolute;top:8px;right: 17%;width: 36px" src="images/face.png" alt="" width="30" style="vertical-align:middle;" />
				<input class="talk_send" type="button" title="发送" value="发送" onclick="fasong()" />
				<div style="width: 200%;background: #fff;" class="hidden  rele re" id="biaoqing" >
					<div class="mui-row fl mui-text-center " style="width: 50%;">
						<div class="mui-col-sm-3 mui-col-xs-3 re ">
							<img class="aui-col-7" src="images/01.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/02.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/03.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/04.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/05.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/06.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/07.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/08.gif" onclick="sendgif(this)">
						</div>
					</div>
					<div class="mui-row fl mui-text-center" style="width: 50%;">
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/09.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/10.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/11.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/12.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/13.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/14.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/15.gif" onclick="sendgif(this)">
						</div>
						<div class="mui-col-sm-3 mui-col-xs-3 re">
							<img class="aui-col-7" src="images/16.gif" onclick="sendgif(this)">
						</div>
					</div>
					
					<div class="biaoqing_nav mui-text-center fix aui-col-10" style="bottom: 5px;z-index: 1000;left: 0;">
						<div class="fl bg_gray bg_gray1" style="width: 15px;height: 15px;border-radius: 50%;z-index: 1000;margin-left: 45%;"></div>
						<div class="fl bg_gray" style="width: 15px;height: 15px;border-radius: 50%;z-index: 1000;margin-left: 20px;"></div>
					</div>
				</div>
				<!--the end--->
			</div>
		

		</div>
		<!-- <!---main_warp end--->
		<aside style="height: 13%;background: white;position: absolute;bottom: -104px;display:none ;">
			<div style="width: 25%;float: left; text-align: center;">
				<a href="room_yaoqing.html"><img style="width: 50%;margin-top: 8px;" src="images/zhannei.png" alt="" /></a>
				<h2>站内好友</h2>
			</div>
			<div style="width: 25%;float: left;text-align: center;">
				<a href="room_yaoqing.html"><img style="width: 50%;margin-top: 8px;" src="images/qq.png" alt="" /></a>
				<h2>qq好友</h2>
			</div>
			<div style="width: 25%;float: left;text-align: center;">
				<a href=""></a><img style="width: 50%;margin-top: 8px;" src="images/weixin_icon.jpg" alt="" />
				<h2>威信好友</h2>
			</div>
			<div style="width: 25%;float: left;text-align: center;">
				<div style="font: 16px/30px '';color: white;background: #f8de47;width:66%;border-radius: 18px;margin:10px auto;">召集令</div>
				<h2 style="margin-top: 14px;">1222钱</h2>
			</div>
		</aside>

		<!-- 商品内容开始 -->
		<div id="cover" class="cover">
			<div class="box re" style=" ">
				<div class="pic ab"></div>
				<h3>
					<h3 class="aui-color-white">商品名称</h3>
				<h4 class="aui-color-white">江湖大冒险：2人模式</h4>
				<h4 class="aui-color-white line">商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称</h4>
				<h4 class="line aui-color-white">商品总价<span class=" aui-color-white">120钱</span></h4>
				<h4 class="line aui-color-white">人均消耗<span class=" aui-color-white">400钱</span></h4>

				<a class="sure re retop" href="">确定</a>
			</div>
		</div>
		</div>
		<!-- 商品内容结束 -->

		<!--房主弹窗-->
		<div id="fangzhu" class="cover ">
			<div class="box re alert_bg" style="z-index: 5;">
				<div class="pic ab alert_bg"></div>
				<div>
					<h3 class="aui-color-white alert_user_name">无</h3>
					<h4 class="aui-color-white" >ID:<span class="alert_id" >0</span></h4>
					<div class="line"></div>
					<div class="hidden aui-color-white">
						<div class="aui-col-5 fl">
							<h3>段位：<span class="alert_dw" >0</span></h3></div>
						<div class="aui-col-4 fl">
							<h3>胜率：<span class="alert_shenglv" >76%</span></h3></div>
							
					</div>
					<div class="line"></div>
					<div class="hidden	aui-color-white">
						<div class="aui-col-5 fl">
							<h3>人气：<span class="alert_focused_count" >0</span></h3></div>
						<div class="aui-col-4 fl">
							<h3>运气：<span class="alert_xingyun" >0</span></h3></div>
					</div>
					<div class="line"></div>
					<div class=" hidden ">
						<div class="pipei-col-50 fl ">
							<a href="javascript:void(0)" class="pipei_btn aui-col-7 inline aui-border-radius-15 add_friend" onclick="add_friend()">加好友</a>
						</div>
						<div class="pipei-col-50 fl">
							<a href="javascript:void(0)" class="pipei_btn pipei_btn1 aui-col-7 inline aui-border-radius-15 send_gift">送礼物</a>
						</div>
					</div>
				</div>
			</div>
			<div>
				<div class=" hidden aui-col-7 aui-background-lightblue aui-border-radius-15 re" style="margin-left: 15%;height: 66px;margin-top:-20px ; re z-index: 1;">
					<div class="pipei-col-50 fl aui-mar-t-10" style="border-right:1px dashed white	;">
						<a href="#" class="tichu aui-col-7 inline aui-border-radius-15 aui-color-white" onclick="alert('')">踢出房间</a>
					</div>
					<div class="pipei-col-50 fl aui-mar-t-10">
						<a href="#" class=" aui-col-7 aui-color-white inline aui-border-radius-15" onclick="$('#fangzhu').hide()">确定</a>
					</div>
				</div>
			</div>
		</div>

		<!--动画end-->
		<div id="gift" class="cover">
			<div class="aui-background-white aui-col-10 ab contain">
				<h4 class="aui-border-b-gray">送给 &nbsp;<span class="gifttousername">无</span></h4>
				<div class="hidden">
					<?if($this->_var['data']['giftlist']):?>
					<?foreach($this->_var['data']['giftlist'] as $k=>$v):?>
					<div class="pipei-col-25 fl" onclick="check_gift(<?=$v['id']?>)">
						<img src="<?=$v['icon']?>" alt="" />
						<h3><?=$v['name']?> </h3>
						<h3>￥<?=$v['current_price']?>钱</h3>
					</div>
					<?endforeach;?>
					<?endif;?>
					<div>
						<h3 class="aui-color-white aui-background-lightblue queding aui-col-2 fr" id="send_gift" onclick="send_gift()"> 确定</h3>
						<h3 class="shuliang fr aui-mar-r-15 ">
						<span id="giftnum">1</span>&nbsp;&nbsp;^
						<ul class="ab rebom mx_border-gray aui-background-white aui-col-2">
							<li>888</li>
							<li>188</li>
							<li>58</li>
							<li>20</li>
							<li>10</li>
							<li>1</li>
						</ul>
					</h3>
					</div>
				</div>
			</div>
		</div>
		<div class="gift_alert ab">
			<img class="fl re" src="images/feiji.png" alt="" />
			<span class="aui-color-white fl re">无送给张歆艺一架飞机</span>
		</div>
		<div class="tichu_alert ab">
			<span class="aui-color-white ">无被踢出了房间</span>
		</div>
		</div>
		<!--gift-->
		</div>
	</body>

</html>
<script src="js/pipei.js"></script>
<script>
      //获取相关CSS属性
       	   $("#biaoqing").hide();
       	   $("#biaoqing").css("bottom",0);
    var getCss = function(o,key){
        return o.currentStyle? o.currentStyle[key] : document.defaultView.getComputedStyle(o,false)[key];   
    };

    function drag(element){
        element.style.left = getCss(element,"left");
        var hammer = new Hammer(element);//hammer实例
        var x = 0;
        var y = 0;
        hammer.on('panstart',function(event){
            x = parseInt(element.style.left);
        });
        hammer.on('panmove',function(event){
        	var a=x + event.deltaX;
        	var b=- document.body.clientWidth
        	if(a>10){
        		element.style.left="10px";
        		$(".biaoqing_nav div").eq(0).removeClass("bg_gray1")
        		$(".biaoqing_nav div").eq(1).removeClass("bg_gray")
        		$(".biaoqing_nav div").eq(1).addClass("bg_gray1")
        	}
//      
        	else if(a<b){
        		element.style.left=b+"px";
        		$(".biaoqing_nav div").eq(0).addClass("bg_gray1")
        		$(".biaoqing_nav div").eq(1).addClass("bg_gray")
        		$(".biaoqing_nav div").eq(1).removeClass("bg_gray1")
        	}
        	else{
        		element.style.left = x + event.deltaX + "px";
        	}
        
           console.log(x + event.deltaX)
        });
        hammer.on('panend',function(event){

        });

    }
    var myElement = document.getElementById("biaoqing");
    drag(myElement);
       $("#xiaolian").click(function(){
    	$(".talk_word").css("bottom","176px")
    	$("#biaoqing").show();
    	if($(".a_yq").show()) {
				$(document).mouseup(function(e) {
					var _con = $("#biaoqing"); // 设置目标区域
					if(!_con.is(e.target) && _con.has(e.target).length === 0) { // Mark 1
						$("#biaoqing").hide();	
						$(".talk_word").css("bottom","0");
					}
				});
			}
    })
</script>
<input type="hidden" value="0" id="toid" />
<input type="hidden" value="0" id="togiftid" />
<script>
function check_gift(id){
	$("#togiftid").val(id);
}
function add_friend(){
	var id=$("#toid").val();
	$(".add_friend").attr("onclick","alert('别急，已经发送过请求啦')");
	$.ajax({
		url: 'index.php?ctl=uc_msg&act=add_friend',
		type: 'POST',
		data: 'id=' + id + '&rnum=' + Math.random(),
		dataType: "json",
		success: function (data) {
			if(data.add_status==1){
				alert("添加成功，等待对方通过好友");
			}
			if(data.add_status==2){
				alert("你们已经是好友啦");
			}
			if(data.add_status==3){
				alert("等待对方通过好友");
			}
		},
		error: function () {
			alert("系统错误，请联系管理员");
		}
	});
}
function send_gift(){
	var toid=$("#toid").val();
	var giftnum=$("#giftnum").html();
	var togiftid=$("#togiftid").val();
	$("#send_gift").attr("onclick","alert('别急，已经发送过请求啦')");
	$.ajax({
		url: 'index.php?ctl=game&act=send_gift',
		type: 'POST',
		data: 'toid=' + toid + '&giftnum=' + giftnum +'&togiftid=' + togiftid +'&rnum=' + Math.random(),
		dataType: "json",
		success: function (data) {
			if(data.status=="1"){
				alert(data.info);
				//location.href="";
				$("#send_gift").attr("onclick","send_gift()");
			}else{
				alert(data.info);
			}
		},
		error: function () {
			//alert("系统错误，请联系管理员");
		}
	});
}
var ws;
function init(join_group_cj) {
	//开放游戏位置
	for (var i=0;i<<?=$_GET['game_num']?>;i++){
		$("#user_logo"+(i+1)).attr("src","images/kongwei.png");
	}
	
	var host = "ws://47.104.8.67:8282";
	try {
		ws = new WebSocket(host);
		ws.onopen = function(){
			console.log('连接成功');
			ws.send("login:"+{$data.user_info.id});
			console.log('发送登陆数据完毕');
			ws.send("join_group_cj:"+join_group_cj);//join_group_cj:deal_id-game_num-userid-userid
			console.log('join_group通知完毕');
		};
		ws.onmessage = function (e) {
			//房间内玩家信息监听 join_group_cj-2-uids
			if(e.data.indexOf("join_group_cj")>=0){
				var n=e.data.split("-");
				//alert(n[1]);
				//n[2]在房间内
				$.ajax({
					url: 'index.php?ctl=game&act=userlist',
					type: 'POST',
					data: 'uids=' +n[2]+ '&t=' + Math.random(),
					dataType: "json",
					success: function (data) {
						console.log(data);
						if(data.userlist){
							$.each(data.userlist,function(k,v){
								$("#user_logo"+(k+1)).attr("src",v['user_logo']);
								$("#user_name"+(k+1)).html(v['user_name']);
								$("#user_logo"+(k+1)).addClass("user_logo"+v['id']);
								$("#user_name"+(k+1)).addClass("user_name"+v['id']);
								$("#user_logo"+(k+1)).click(function(){
									$(".alert_user_name").html(v['user_name']);
									$(".alert_dw").html(v['dw']);
									$(".alert_id").html(v['id']);
									$(".alert_focused_count").html(v['focused_count']);
									$(".alert_xingyun").html(v['xingyun']);
									$(".gifttousername").val(v['user_name']);
									$("#toid").val(v['id']);
									$("#fangzhu").show();
								});
							});
						}
					},
					error: function () {
						//alert("系统错误，请联系管理员");
					}
				});		
			}
			//监听退出事件 out_group_cj-2-userid
			if(e.data.indexOf("out_group_cj")>=0){
				var n=e.data.split("-");
				//alert(n[1]);
				//n[2]退出
				$(".user_logo"+n[2]).attr("src","images/kongwei.png");
				$(".user_name"+n[2]).html('无');
				$(".user_logo"+n[2]).removeClass("user_logo"+n[2]);
				$(".user_name"+n[2]).removeClass("user_name"+n[2]);
				
			}
			//监听聊天事件 liaotian-userid-liaotian
			if(e.data.indexOf("liaotian")>=0){
				var n=e.data.split("-");
				//alert(n[1]);
				//n[1]发送人userid
				//n[2]聊天内容
				var liaotiancontent='';
				if(n[1]!=<?=$GLOBALS ['user_info']['id']?>){
					liaotiancontent+='<div class="aui-mar-b-15 hidden">';
					liaotiancontent+='<img src="'+$(".user_logo"+n[1]).attr("src")+'" class="aui-border-rasius-y fl aui-mar-r-10" width="34">';
					liaotiancontent+='<div class="chat_txt aui-col-7 aui-background-gray aui-pad-10 aui-border-1 aui-border-radius re fl">'+n[2]+'</div></div>';
				}else{
					liaotiancontent+='<div class="aui-mar-b-15 hidden">';
					liaotiancontent+='<img src="'+$(".user_logo"+n[1]).attr("src")+'" class="aui-border-rasius-y fr aui-mar-l-10" alt="" width="34">';
					liaotiancontent+='<div style="background: #b1e46e;" class="chat_txt chat_r aui-col-7  aui-pad-10 aui-border-1 aui-border-radius re fr">'+n[2]+'</div></div>';
				}

				$("#liaotianneirong").html(liaotiancontent+$("#liaotianneirong").html());
			}
			//监听聊天gif事件 ltgif-userid-liaotian
			if(e.data.indexOf("ltgif")>=0){
				var n=e.data.split("-");
				//alert(n[1]);
				//n[1]发送人userid
				//n[2]聊天内容
				var liaotiancontent='';
				if(n[1]!=<?=$GLOBALS ['user_info']['id']?>){
					liaotiancontent+='<div class="aui-mar-b-15 hidden">';
					liaotiancontent+='<img src="'+$(".user_logo"+n[1]).attr("src")+'" class="aui-border-rasius-y fl aui-mar-r-10" width="34">';
					liaotiancontent+='<img class="fl" src="'+n[2]+'" style="width:60px" /></div>';
				}else{
					liaotiancontent+='<div class="aui-mar-b-15 hidden">';
					liaotiancontent+='<img src="'+$(".user_logo"+n[1]).attr("src")+'" class="aui-border-rasius-y fr aui-mar-l-10" alt="" width="34">';
					liaotiancontent+='<img class="fr" src="'+n[2]+'"  style="width:60px" /></div>';
				}

				$("#liaotianneirong").html(liaotiancontent+$("#liaotianneirong").html());
			}
			//监听人满开车
			if(e.data.indexOf("group_ok")>=0){
				console.log('开车啦');
				var n=e.data.split("-");
				var oneuser=n[1].split(",");
				if(oneuser[0]=={$data.user_info.id}){
					var deal_id =<?=$_GET['deal_id']?>;
					var game_num=<?=$_GET['game_num']?>;
					$.ajax({
						url: 'index.php?ctl=baozang&act=goumai2',
						type: 'POST',
						data: 'deal_id=' + deal_id + '&game_num=' + game_num + '&type=1&uids=' + n[1] +'&t=' + Math.random(),
						dataType: "json",
						success: function (data) {
							//console.log(data);
							if(data.status=="1"){
								ws.send("doing_cj:<?=$_GET['group_name']?>"+"-"+data.deal_id);//发车成功 doing:deal_id-game_num-deal_id
							}else{
								alert(data.info);
							}
						},
						error: function () {
							//alert("系统错误，请联系管理员");
						}
					});				
				}
			}
			//监听发车成功
			if(e.data.indexOf("doing_cj")>=0){
				var n=e.data.split("-");
				window.location.href='index.php?ctl=game&act=doing&deal_id='+n[1];
			}
			console.log('监听消息:'+e.data);
		};
		ws.onclose = function (msg) {
			console.log('关闭连接');
		};
	}
	catch (ex) {
		console.log(ex);
	}
}
init("<?=$_GET['group_name']?>-<?=$GLOBALS ['user_info']['id']?>");
function fasong(){
	var liaotian=$("#liaotian").val();
	send("liaotian:<?=$_GET['group_name']?>-<?=$GLOBALS ['user_info']['id']?>-"+liaotian);
}
function sendgif(obj){
	var gif=$(obj).attr("src");
	send("ltgif:<?=$_GET['group_name']?>-<?=$GLOBALS ['user_info']['id']?>-"+gif);
}
function send(msg) {
	try { 
		ws.send(msg); 
	} catch (ex) { 
		console.log(ex);
	}
}
//刷新或关闭
window.onbeforeunload = function () {
	try {
		//监听异常退出事件
		ws.send("out_group_cj:<?=$_GET['group_name']?>-<?=$GLOBALS ['user_info']['id']?>");//out_group_cj:deal_id-game_num-userid
		ws.close();
		ws = null;
	}
	catch (ex) {
		console.log(ex);
	}
};
//手动关闭
function close_ws(){
	try {
		//监听点击取消事件
		ws.send("out_group_cj:<?=$_GET['group_name']?>-<?=$GLOBALS ['user_info']['id']?>");//out_group_cj:deal_id-game_num-userid
		ws.close();
		ws = null;
	}
	catch (ex) {
		console.log(ex);
	}
}
</script>

